package comviva.msisdn;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;

public class Main {
	private static final int CAPACITY = 65536;
	private static final LongHashSet hash_set = new LongHashSet(CAPACITY >> 1);
	private static byte[] buff = new byte[128];
	private static int buff_size = 0;
	private static final StringBuilder result = new StringBuilder(CAPACITY >> 3);
	private static final String FAILURE = "Failure";

	public static void main(String[] args) throws IOException {
		solve();

	}

	private static void solve() throws IOException {

		final byte[] t_buff = new byte[CAPACITY];
		int len;
		while ((len = System.in.read(t_buff)) > 0) {
			int newCount = buff_size + len;
			if (newCount > buff.length) {
				System.out.println("newC: " + newCount + ", buff.length <<1: "
						+ (buff.length << 1));
				buff = Arrays.copyOf(buff,
						Math.max(buff.length << 1, newCount) + 1);
			}
			System.arraycopy(t_buff, 0, buff, buff_size, len);
			buff_size = newCount;
		}
		buff[buff_size++] = ',';

		int si = 0;
		int ei = -1;
		long hash = -1;
		do {
			ei = indexOfSeparator(si);
			if (ei != -1) {
				hash = checkValidMSISDN(si, ei - 1);
				if (hash != -1) {
					hash_set.add(hash);
				}
				if (buff[ei] == '|') {
					break;
				}

				si = ei + 1;
			}
		} while (ei != -1);

		if (ei == -1) {
			System.out.print(FAILURE);
			return;
		}

		si = ei + 1;
		ei = -1;
		hash = -1;
		do {
			ei = indexOfSeparator(si);
			if (ei != -1) {
				hash = checkValidMSISDN(si, ei - 1);
				if (hash != -1) {
					if (hash_set.contains(hash)) {
						result.append('F');
					} else {
						result.append('M');
					}
				}
				if (buff[ei] == '|') {
					break;
				}
				si = ei + 1;
			}

		} while (ei != -1);

		if (result.length() == 0 || ei != -1) {
			System.out.print(FAILURE);
			return;
		}

		PrintStream ps = new PrintStream(new BufferedOutputStream(System.out,
				result.length()));

		ps.print(result);
		ps.flush();
		ps.close();

	}

	private static final long checkValidMSISDN(int start, int end) {
		if (end < 0)
			return -1;

		while (buff[start] == ' ' && start < end)
			start++;

		while (buff[end] == ' ' && start < end)
			end--;

		if (start > end || end < 0)
			return -1;

		if (start + 2 <= end && buff[start] == '+' && buff[start + 1] == '9'
				&& buff[start + 2] == '1') {
			start += 3;
		} else if (buff[start] == '0') {
			start++;
		}

		long hash = 5381;

		byte b;
		for (int i = start; i <= end; i++) {
			b = buff[i];
			if (b >= '0' && b <= '9') {
				hash = ((hash << 5) + hash) + b;
			} else
				return -1;
		}

		return hash;

	}

	private static final int indexOfSeparator(final int fromIndex) {
		for (int i = fromIndex; i < buff_size; i++) {
			final byte b = buff[i];
			if (b == ',' || b == '|')
				return i;
		}
		return -1;
	}

	static class LongHashSet {
		static final int DEFAULT_INITIAL_CAPACITY = 16;
		static final int MAXIMUM_CAPACITY = 1 << 30;
		static final float DEFAULT_LOAD_FACTOR = 0.75f;
		Entry[] table;
		int size;
		int threshold;
		final float loadFactor;

		public LongHashSet(int initialCapacity) {
			this.loadFactor = 0.75f;
			threshold = (int) (initialCapacity * loadFactor);
			table = new Entry[initialCapacity];
		}

		public int add(long key) {
			int hash = hash(key);
			int i = indexFor(hash, table.length);
			for (Entry e = table[i]; e != null; e = e.next) {
				if (e.hash == hash && e.key == key) {
					return 0;
				}
			}

			addEntry(hash, key, i);
			return -1;
		}

		static int hash(long hh) {
			int h = (int) (hh ^ (hh >>> 32));
			h ^= (h >>> 20) ^ (h >>> 12);
			return h ^ (h >>> 7) ^ (h >>> 4);
		}

		static int indexFor(int h, int length) {
			return h & (length - 1);
		}

		void addEntry(int hash, long key, int bucketIndex) {
			Entry e = table[bucketIndex];
			table[bucketIndex] = new Entry(hash, key, e);
			if (size++ >= threshold)
				resize(2 * table.length);
		}

		void resize(int newCapacity) {
			Entry[] oldTable = table;
			int oldCapacity = oldTable.length;
			if (oldCapacity == MAXIMUM_CAPACITY) {
				threshold = Integer.MAX_VALUE;
				return;
			}

			Entry[] newTable = new Entry[newCapacity];
			transfer(newTable);
			table = newTable;
			threshold = (int) (newCapacity * loadFactor);
		}

		void transfer(Entry[] newTable) {
			Entry[] src = table;
			int newCapacity = newTable.length;
			for (int j = 0; j < src.length; j++) {
				Entry e = src[j];
				if (e != null) {
					src[j] = null;
					do {
						Entry next = e.next;
						int i = indexFor(e.hash, newCapacity);
						e.next = newTable[i];
						newTable[i] = e;
						e = next;
					} while (e != null);
				}
			}
		}

		final boolean contains(long key) {
			int hash = hash(key);
			for (Entry e = table[indexFor(hash, table.length)]; e != null; e = e.next) {
				if (e.hash == hash && e.key == key)
					return true;
			}
			return false;
		}

		static class Entry {
			final long key;
			Entry next;
			final int hash;

			Entry(int h, long k, Entry n) {
				next = n;
				key = k;
				hash = h;
			}

			public final boolean equals(Object o) {
				if (!(o instanceof Entry))
					return false;
				Entry e = (Entry) o;
				if (this.key == e.key) {
					return true;
				}
				return false;
			}

			public final int hashCode() {
				System.out.println("hashCode");
				return (int) (key ^ (key >>> 32));
				// return key ^ value;
			}

		}
	}
}
